Skip to content

Validate present optional record fields at runtime - #3137

Merged
soutaro merged 2 commits into
ruby:masterfrom
OskarEichler:codex/optional-record-fields
Sep 7, 2026
Merged

Validate present optional record fields at runtime#3137
soutaro merged 2 commits into
ruby:masterfrom
OskarEichler:codex/optional-record-fields

Conversation

@OskarEichler

Copy link
Copy Markdown
Contributor

Summary

Runtime record validation checks required fields but ignores optional_fields entirely. A present optional field therefore passes even when its value is incompatible with the declared type.

Validate optional fields only when their key is present, preserving their optional presence contract.

Verification

  • baseline model accepts an invalid present optional value; focused and cumulative candidates reject it while accepting absent/valid values
  • runtime type-checking tests: 15 tests / 302 assertions
  • all 109 runtime files compile on Ruby 4.0.6
  • focused candidate syntax, RuboCop, and diff checks pass

Source-only change; no test file is included.

@soutaro soutaro self-assigned this Sep 7, 2026
@soutaro
soutaro enabled auto-merge September 7, 2026 07:56
@soutaro
soutaro added this pull request to the merge queue Sep 7, 2026
Merged via the queue into ruby:master with commit 60be129 Sep 7, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants